import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D  # 3D 绘图支持

# 生成数据
x = np.linspace(0, 10, 500)
y = np.sin(x)
z = np.cos(x)

# 创建 3D 图像
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# 绘制 3D 曲线
ax.plot(x, y, z, label='3D sin(x)-cos(x)')
ax.set_xlabel('X')
ax.set_ylabel('sin(x)')
ax.set_zlabel('cos(x)')
ax.legend()

# 保存为图片
plt.savefig("plot.png")
print("✅ 图像已保存为 plot.png")
